import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';

//引入全局样式
import '@/style/global.scss';

//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import * as ws from '@/config/ws';

 import '@/tools/toolsExample'
Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
  beforeCreate() {
    // 需要在全局添加一个属性
    Vue.prototype.$bus = this;
    Vue.prototype.$ws = ws;
  }
}).$mount('#app');

// Vue.prototype.$ws.init()
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面meta */
  if (to.meta.content) {
    let head = document.getElementsByTagName('head');
    let meta = document.createElement('meta');
    meta.content = to.meta.content;
    head[0].appendChild(meta);
  }
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    console.log('路由发生变化了', to);
    document.title = to.meta.title;
   
  }
  next();
});
